define('app/demo/audit/auditedit', function(require, exports, module) {
	'use strict';
	var $ = require('jquery');
	var Widget = require('arale-widget/1.2.0/widget');
	var Dialog = require("optDialog/src/dialog");
	// var Paging = require('paging/0.0.1/paging-debug');
	var AjaxController = require('opt-ajax/1.0.0/index');
	require("jsviews/jsrender.min");
	require("jsviews/jsviews.min");
	require("my97DatePicker/WdatePicker");
	require("bootstrap-paginator/bootstrap-paginator.min");
	require("app/util/jsviews-ext");
	require("opt-paging/aiopt.pagination");

	var SendMessageUtil = require("app/util/sendMessage");

	// 实例化AJAX控制处理对象
	var ajaxController = new AjaxController();
	// var clickId = "";
	// 定义页面组件类
	var addlistPager = Widget.extend({

		Implements : SendMessageUtil,
		// 属性，使用时由类的构造函数传入
		attrs : {
			clickId : ""
		},
		Statics : {
			DEFAULT_PAGE_SIZE : 10
		},
		// 事件代理
		events : {
			"click #commitBtn" : "commitAudit",
			"click #cancelBtn" : "cancelAudit",
			"click #selectHis" : "_queryHis"
		},
		// 重写父类
		setup : function() {
			addlistPager.superclass.setup.call(this);
		},

		_queryHis : function() {
			var _this = this;
			var taskId = $("#taskId").val().trim();
			$("#pagination-ul").runnerPagination(
					{
						url : _base + "/auditdemo/queryHis",
						method : "POST",
						dataType : "json",
						renderId : "searchAuditData",
						messageId : "showMessageDiv",
						pageSize : addlistPager.DEFAULT_PAGE_SIZE,
						visiblePages : 5,
						data : {
							"taskId" : taskId
						},
						render : function(data) {
							if (data != null && data !== 'undefined'
									&& data.length > 0) {
								var template = $
										.templates("#searchNormProductTemple");
								var htmlOutput = template.render(data);
								$("#searchAuditData").html(htmlOutput);
							}
							_this._returnTop();
						}
					});
		},

		cancelAudit : function() {
			var taskId = $("#taskId").val().trim();
			ajaxController.ajax({
				type : "post",
				processing : false,
				url : _base + "/auditdemo/cancelcommit",
				data : {
					"taskId" : taskId
				// other param...
				},
				success : function(data) {
					if (data != null && data !== 'undefined') {
						var s = Dialog({
							content : "完成",
							okValue : '确 定',
							title : '提示',
							ok : function() {
								this.close();
							}
						});
						s.show();
					} else {
						var d = Dialog({
							content : "获取类目信息出错",
							icon : 'fail',
							okValue : '确 定',
							title : '提示',
							ok : function() {
								this.close();
							}
						});
						d.show();
					}
				}
			});
		},

		commitAudit : function() {
			var taskId = $("#taskId").val().trim();
			var productName = $('#productName').val();
			var productPrice = $("#productPrice").val();
			ajaxController.ajax({
				type : "post",
				processing : false,
				url : _base + "/auditdemo/recommit",
				data : {
					"taskId" : taskId,
					'productName' : productName,
					'productPrice' : productPrice
				},
				success : function(data) {
					if (data != null && data !== 'undefined') {
						var s = Dialog({
							content : "完成",
							okValue : '确 定',
							title : '提示',
							ok : function() {
								this.close();
							}
						});
						s.show();
					} else {
						var d = Dialog({
							content : "获取类目信息出错",
							icon : 'fail',
							okValue : '确 定',
							title : '提示',
							ok : function() {
								this.close();
							}
						});
						d.show();
					}
				}
			});
		},

		// 显示信息
		_showSuccessMsg : function(msg) {
			var d = Dialog({
				content : msg,
				okValue : '确 定',
				title : '提示',
				ok : function() {
					this.close();
				}
			});
			d.show();
		},
		// 滚动到顶部
		_returnTop : function() {
			var container = $('.wrapper-right');
			container.scrollTop(0);// 滚动到div 顶部
		},

	});

	module.exports = addlistPager;
});
